/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package project;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author jon
 */
public class Property {
    private int property_number;
    private int employee_number;
    private int popularity;
    private String property_owner;
    private String property_type;
    private double monthly_mgt_fee;
    private double max_rent;
    private double min_rent;
    private int num_bedrooms;
    private int num_bathrooms;
    private double monthly_rent;
    private Date date_last_asking_rent;
    private int square_feet;
    private int address_zipcode;
    private String address_state;
    private String address_city;
    private String address_street;

    public Property(int property_number, int employee_number, int popularity, String property_owner, String property_type, double monthly_mgt_fee, double max_rent, double min_rent, int num_bedrooms, int num_bathrooms, double monthly_rent, Date date_last_asking_rent, int square_feet, int address_zipcode, String address_state, String address_city, String address_street) {
        this.property_number = property_number;
        this.employee_number = employee_number;
        this.popularity = popularity;
        this.property_owner = property_owner;
        this.property_type = property_type;
        this.monthly_mgt_fee = monthly_mgt_fee;
        this.max_rent = max_rent;
        this.min_rent = min_rent;
        this.num_bedrooms = num_bedrooms;
        this.num_bathrooms = num_bathrooms;
        this.monthly_rent = monthly_rent;
        this.date_last_asking_rent = date_last_asking_rent;
        this.square_feet = square_feet;
        this.address_zipcode = address_zipcode;
        this.address_state = address_state;
        this.address_city = address_city;
        this.address_street = address_street;
    }


    /**
     * @return the property_number
     */
    public int getProperty_number() {
        return property_number;
    }

    /**
     * @param property_number the property_number to set
     */
    public void setProperty_number(int property_number) {
        this.property_number = property_number;
    }

    /**
     * @return the popularity
     */
    public int getPopularity() {
        return popularity;
    }

    /**
     * @param popularity the popularity to set
     */
    public void setPopularity(int popularity) {
        this.popularity = popularity;
    }

    /**
     * @return the property_owner
     */
    public String getProperty_owner() {
        return property_owner;
    }

    /**
     * @param property_owner the property_owner to set
     */
    public void setProperty_owner(String property_owner) {
        this.property_owner = property_owner;
    }

    /**
     * @return the property_type
     */
    public String getProperty_type() {
        return property_type;
    }

    /**
     * @param property_type the property_type to set
     */
    public void setProperty_type(String property_type) {
        this.property_type = property_type;
    }

    /**
     * @return the monthly_mgt_fee
     */
    public double getMonthly_mgt_fee() {
        return monthly_mgt_fee;
    }

    /**
     * @param monthly_mgt_fee the monthly_mgt_fee to set
     */
    public void setMonthly_mgt_fee(double monthly_mgt_fee) {
        this.monthly_mgt_fee = monthly_mgt_fee;
    }

    /**
     * @return the max_rent
     */
    public double getMax_rent() {
        return max_rent;
    }

    /**
     * @param max_rent the max_rent to set
     */
    public void setMax_rent(double max_rent) {
        this.max_rent = max_rent;
    }

    /**
     * @return the min_rent
     */
    public double getMin_rent() {
        return min_rent;
    }

    /**
     * @param min_rent the min_rent to set
     */
    public void setMin_rent(double min_rent) {
        this.min_rent = min_rent;
    }

    /**
     * @return the num_bedrooms
     */
    public int getNum_bedrooms() {
        return num_bedrooms;
    }

    /**
     * @param num_bedrooms the num_bedrooms to set
     */
    public void setNum_bedrooms(int num_bedrooms) {
        this.num_bedrooms = num_bedrooms;
    }

    /**
     * @return the num_bathrooms
     */
    public int getNum_bathrooms() {
        return num_bathrooms;
    }

    /**
     * @param num_bathrooms the num_bathrooms to set
     */
    public void setNum_bathrooms(int num_bathrooms) {
        this.num_bathrooms = num_bathrooms;
    }

    /**
     * @return the monthly_rent
     */
    public double getMonthly_rent() {
        return monthly_rent;
    }

    /**
     * @param monthly_rent the monthly_rent to set
     */
    public void setMonthly_rent(double monthly_rent) {
        this.monthly_rent = monthly_rent;
    }

    /**
     * @return the date_last_asking_rent
     */
    public Date getDate_last_asking_rent() {
        return date_last_asking_rent;
    }

    /**
     * @param date_last_asking_rent the date_last_asking_rent to set
     */
    public void setDate_last_asking_rent(Date date_last_asking_rent) {
        this.date_last_asking_rent = date_last_asking_rent;
    }

    /**
     * @return the square_feet
     */
    public int getSquare_feet() {
        return square_feet;
    }

    /**
     * @param square_feet the square_feet to set
     */
    public void setSquare_feet(int square_feet) {
        this.square_feet = square_feet;
    }

    /**
     * @return the address_zipcode
     */
    public int getAddress_zipcode() {
        return address_zipcode;
    }

    /**
     * @param address_zipcode the address_zipcode to set
     */
    public void setAddress_zipcode(int address_zipcode) {
        this.address_zipcode = address_zipcode;
    }

    /**
     * @return the address_state
     */
    public String getAddress_state() {
        return address_state;
    }

    /**
     * @param address_state the address_state to set
     */
    public void setAddress_state(String address_state) {
        this.address_state = address_state;
    }

    /**
     * @return the address_city
     */
    public String getAddress_city() {
        return address_city;
    }

    /**
     * @param address_city the address_city to set
     */
    public void setAddress_city(String address_city) {
        this.address_city = address_city;
    }

    /**
     * @return the address_street
     */
    public String getAddress_street() {
        return address_street;
    }

    /**
     * @param address_street the address_street to set
     */
    public void setAddress_street(String address_street) {
        this.address_street = address_street;
    }

    /**
     * @return the employee_number
     */
    public int getEmployee_number() {
        return employee_number;
    }

    /**
     * @param employee_number the employee_number to set
     */
    public void setEmployee_number(int employee_number) {
        this.employee_number = employee_number;
    }

    public void insert()
    {
    try
        {
            String host = "jdbc:oracle:thin:@localhost:1521:xe";
            String username = "jon";
            String password = "chaosecco";
            String driverName = "oracle.jdbc.driver.OracleDriver";
            Class.forName(driverName);

            Connection connection = DriverManager.getConnection(host,
                    username, password);
            System.out.print("Connected successfully.");
            String insertQuery = "INSERT INTO PROPERTY_FOR_RENT(" +
                    "property_number, " +
                    "employee_number, " +
                    "popularity, " +
                    "property_owner, " +
                    "property_type, " +
                    "monthly_mgt_fee, "  +
                    "maximum_rent, " +
                    "minimum_rent, " +
                    "num_bedrooms, " +
                    "num_bathrooms, " +
                    "monthly_rent, " +
                    "date_last_asking_rent, " +
                    "square_feet, " +
                    "property_address_zipcode, " +
                    "property_address_state, " +
                    "property_address_city, " +
                    "property_address_street)" +
                    "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," +
                    "?, ?, ?, ?, ?, ?)";
            PreparedStatement ps = connection.prepareStatement(insertQuery);
            ps.setInt(1, property_number);
            ps.setInt(2, employee_number);
            ps.setInt(3, popularity);
            ps.setString(4, property_owner);
            ps.setString(5, property_type);
            ps.setDouble(6, monthly_mgt_fee);
            ps.setDouble(7, max_rent);
            ps.setDouble(8, min_rent);
            ps.setInt(9, num_bedrooms);
            ps.setInt(10, num_bathrooms);
            ps.setDouble(11, monthly_rent);
            ps.setDate(12, date_last_asking_rent);
            ps.setInt(13, square_feet);
            ps.setInt(14, address_zipcode);
            ps.setString(15, address_state);
            ps.setString(16, address_city);
            ps.setString(17, address_street);
            ps.executeUpdate();

            connection.close();
        }

        catch (SQLException e)
        {
            System.out.println("ERROR: " + e.getMessage());
        }

        catch(ClassNotFoundException e)
        {
            System.out.println("ERROR: " + e.getMessage());
        }
    }

}
